package com.yc3.user;

import com.yc3.system.ContainerFilter;
import org.springframework.stereotype.Component;

/**
 * @ClassName StudentBmiFilter
 * @since: 2023/7/26 10:00
 * @auth: kirito
 * @description:
 **/
@Component("bmifilter")
public class StudentBmiFilter implements ContainerFilter {
    @Override
    public boolean doFilter(Object object) {
        if (object == null) {
            return false;
        }
        if (!(object instanceof student)) {
            return false;
        }
        student s = (student)object;
        if (s.getName() == null || "".equalsIgnoreCase(s.getName())) {
            return false;
        }
        if (s.getHeight() < 1 || s.getHeight() > 2.7) {
            System.out.println("身高数据异常" + object.toString());
            return false;
        }
        if (s.getWeight() < 30 || s.getWeight() > 500) {
            System.out.println("体重数据异常" + object.toString());
            return false;
        }
        return true;
    }
}
